package com.ssm.service;

import org.springframework.beans.factory.annotation.Autowired;

import com.ssm.dao.BaseDao;

public class BaseService {

	@Autowired
	private BaseDao baseDao;
	
	public String getId(String seqId, String prefix, int length) {
		baseDao.update(seqId);
		int seq = baseDao.getId(seqId);
		prefix = prefix == null ? "" : prefix;
		StringBuffer sb = new StringBuffer(prefix);
		for (int i=0; i<length-prefix.length() - String.valueOf(seq).length(); i++) {
			sb.append("0");
		}
		sb.append(seq);
		return sb.toString();
	}
}
